# Maintainer: Felix Yan <felixonmars@archlinux.org>

_hkgname=crypto-api-tests
pkgname=haskell-crypto-api-tests
pkgver=0.3
pkgrel=246
pkgdesc="A test framework and KATs for cryptographic operations."
url="http://trac.haskell.org/crypto-api/wiki"
license=('BSD')
arch=('loong64' 'x86_64')
depends=('ghc-libs' 'haskell-test-framework-quickcheck2' 'haskell-crypto-api' 'haskell-cereal'
         'haskell-test-framework' 'haskell-test-framework-hunit' 'haskell-hunit'
         'haskell-quickcheck')
makedepends=('ghc')
source=(https://hackage.haskell.org/packages/archive/${_hkgname}/${pkgver}/${_hkgname}-${pkgver}.tar.gz)
sha512sums=('4d9dfd52dc67279a712bd444972faa6650d987c8f65fb41178e5c6523a7260c0e2df8f44bc511ffa217b6d71c5ec41ab11a0466a326c9133f7e20c01c37404d5')

build() {
    cd $_hkgname-$pkgver
    
    runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
        --prefix=/usr --docdir=/usr/share/doc/$pkgname --datasubdir=$pkgname \
        --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid --ghc-option=-fllvm
    runhaskell Setup build $MAKEFLAGS
    runhaskell Setup register --gen-script
    runhaskell Setup unregister --gen-script
    sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
    sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}

package() {
    cd $_hkgname-$pkgver
    
    install -D -m744 register.sh "$pkgdir"/usr/share/haskell/register/$pkgname.sh
    install -D -m744 unregister.sh "$pkgdir"/usr/share/haskell/unregister/$pkgname.sh
    runhaskell Setup copy --destdir="$pkgdir"
    install -D -m644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
    rm -f "$pkgdir"/usr/share/doc/$pkgname/LICENSE
}
